<!--
<script src="js/up-img.js" type="text/javascript"></script>
<script type="text/javascript" src="js/utils.js"></script>
-->

<style>
.pay-bz-top { width:430; height:auto; border-bottom:1px solid #C8C8C8; padding:10px; margin-bottom:20px; text-align:center;}
.pay-bz-tips { width:430px; border:1px dashed #4A6FFF; margin:auto; text-align:left;}
.pay-bz-tips li { color:#868686; margin:5px; list-style:none;}
.pay-tips-a { color:#868686; text-decoration:none;}
.pay-tips-a:hover { color:#F00; text-decoration:underline;}
.up-foot-pic { display:inline-block; width:175px; height:100px; float:left;}
.bz-pay-bt { width:180px; height:40px; color:#FFF; font-family:微软雅黑; background:#c40000; margin:auto; border:none; border-radius:3px; cursor:pointer;}
.bz-pay-bt:hover { background:#ae0808;}
.in-text { width:230px; border:1px solid #868686; height:23px; padding-left:3px;}
.check-bt { width:60px; border:1px solid #868686; height:25px; cursor:pointer;}
</style>


<div class="pay-bz-top">
    <div class="pay-bz-tips">
        <li>● 严禁使用聚来宝、集分宝、返利网、淘宝客、信用卡、花呗等进行拍宝贝付款</li>
        <li>● 不按要求处理任务会受处罚，请确认您确实已在淘宝对宝贝付款再点确认按钮（垫付单）</li>
        <li>● 付款后请及时按要求确认收货打5分好评</li>
        <!--<li>● <a href="#" target="_blank" class="pay-tips-a">付款注意事项</a></li>-->
    </div>
</div>
<div id="check-pro" style="margin-bottom:10px;">
	<span style="cursor:pointer; color:#5CAB5C;">核对宝贝链接 >></span>
	<div style="display:none; padding-left:20px;">
		输入宝贝链接：
		<input type="text" placeholder="输入宝贝链接" class="in-text" />
		<input type="button" value="&nbsp;验证&nbsp;" class="check-bt" />
	</div>
</div>
<div id="browse-foot">
	<div class="up-foot-pic">
    	<span style="line-height:30px;">上传主宝贝详情页底部截图：</span>
        <a class="pay-tips-a" style="line-height:50px;" href="forum-read.html?id=41190" target="_blank">查看示例</a>
    </div>
	<div id="doing-bottomPic" style="display:inline-block;">
    	<script>Utils.upLoadImg('doing-bottomPic', 'up-img-b.html', 2);</script>
    </div>
</div>
<BR>
<div style="text-align:center;">
    <input type="button" value="已经在淘宝付款" class="bz-pay-bt" id="bz-pay-bt" />
</div>



<script>
$(function() {
	//alert(JSON.stringify(Data.taskObj));
	if(Data.taskObj.browseFoot == 0 || Data.taskObj.phoneOrder == 1) {
		$("#browse-foot").hide();
	}
	if(Data.taskObj.orderType == 2) { //访客单
		$(".pay-bz-tips").children("li").remove();
		$(".pay-bz-tips").append('<li>● 请按任务要求完成浏览，并点击“完成任务”按钮</li>');
		$("#bz-pay-bt").val("完成任务");
	}
	if(Data.taskObj.refundType == 4) {	//远程单
		$("#bz-pay-bt").val("已经在淘宝下订单");
	}
});

/**
 * 核对宝贝链接
 */
$("#check-pro span").click(function() {
	if($("#check-pro div").css("display") == "none") {
		$("#check-pro div").show();
	} else {
		$("#check-pro div").hide();
	}
});

/**
 * 点击验证
 */
$(".check-bt").click(function() {
	var productLink = $.trim($(".in-text").val());
	if(productLink.length < 10) {
		Utils.msgDialog("请输入有效的宝贝链接！");
		return ;
	}
	
	var params = {
		"taskId": Data.taskObj.taskId,
		"productLink": productLink,
	};
	AQ.callAQ("checkProductLink.do", params, function(result) {
		Utils.msgDialog("<span style='color:#388738; font-weight:bold;'>√ 宝贝链接正确！</span>");
	}, function(err, code){
		if(code == 8) {
			Utils.msgDialog("<span style='color:#FF4100; font-weight:bold;'>× 宝贝链接不正确！</span>");
		} else {
			Utils.msgDialog(err+"[code:"+code+"]");
		}
	});
});

$("#bz-pay-bt").click(function() {
	var orderType = Data.taskObj.orderType;
	if(orderType == 1) {	//销量单
		submitPay();
	} else if(orderType == 2) {	//访客单
		if(Data.taskObj.phoneOrder == 0) {	//电脑访客单
			var bottomPic = $("#imgUrl_doing-bottomPic").val();	
			if(Data.taskObj.browseFoot == 1 && bottomPic.length < 10) {
				Utils.msgDialog("请上传“宝贝详情页底部”截图！");
				return ;
			}
		}
		var params = Data.params;
		params.bottomPic = bottomPic;
		submitData(params);
	}
});
	
/*
销量单：已经在淘宝付款
*/
function submitPay() {
	var taskId = Data.taskObj.taskId;
	var refundType = Data.taskObj.refundType;
	var bottomPic = $("#imgUrl_doing-bottomPic").val();
	
	if(Data.taskObj.phoneOrder == 0 && Data.taskObj.browseFoot == 1 && bottomPic.length < 10) {
		Utils.msgDialog("请上传“宝贝详情页底部”截图！");
		return ;
	}
	
	var param = {
		"taskId": taskId,
		"bottomPic": bottomPic,
	};
	AQ.callAQ("hasPay.do", param, function(result) {
		$("#bz-pay-bt").css("background", "#DDDDDD");
		$("#bz-pay-bt").prop("disabled", true);
		
		var content = '<p style="color:#FE5352; font-size:18px; font-weight:bold; text-align:center;">操作成功</p>';
		if(refundType == 1) {
			content += '<span style="color:#FE5352">该任务是平台立返单：<BR>请QQ联系放单方确认已付款，若放单方24小时内未确认已付款，系统自动返款到您的飞钻网账户。</span>';
		} else if(refundType == 2) {
			content += '<span style="color:#FE5352">该任务是商家立返单：<BR>请QQ联系放单方给您返款，若对方拒绝返款，或故意拖延时间超过1小时未返款，请在淘宝申请退款。</span>';
		} else if(refundType == 3) {
			content += '<span style="color:#FE5352">该任务是担保押款单：<BR>请根据物流消息，及时确认收货，打全5分好评。放单方确认已好评后，系统自动返款到您的飞钻网账户。</span>';
		} else if(refundType == 4) {
			content += '<span style="color:#FE5352">该任务是远程单：<BR>请立即QQ联系放单方进行远程付款。</span>';
		}
		if(!(window.location.href.indexOf("doing-take") >= 0)) {	//不在处理任务页面时
			$(".ui-dialog").remove();
			$(".ui-popup-backdrop").remove();
		}
		Utils.checkDialog(content, "确定", "返回", function() {
			$(".ui-dialog").remove();
			$(".ui-popup-backdrop").remove();
			if(window.location.href.indexOf("doing-take") >= 0) {	//在处理任务页面时，关闭当前页
				Utils.closeCurrentPage();
			}
		}, function() {
			$(".ui-dialog").remove();
			$(".ui-popup-backdrop").remove();
			if(window.location.href.indexOf("doing-take") >= 0) {
				Utils.closeCurrentPage();
			}
		});
	}, function(err, code){
		Utils.msgDialog(err+"[code:"+code+"]");
	});
}

/*
访客单：确认完成任务
*/
function submitData(params) {
	AQ.callAQ("browsePro.do", params, function(result) {
		$("#bz-pay-bt").css("background", "#DDDDDD");
		$("#bz-pay-bt").prop("disabled", true);
		
		Utils.checkDialog("成功完成任务啦！", "确定", "返回", function() {
				$(".ui-dialog").remove();
				$(".ui-popup-backdrop").remove();
				if(window.location.href.indexOf("doing-take") >= 0) {	//在处理任务页面时，关闭当前页
					Utils.closeCurrentPage();
				}
			}, function() {
				$(".ui-dialog").remove();
				$(".ui-popup-backdrop").remove();
				if(window.location.href.indexOf("doing-take") >= 0) {	//在处理任务页面时，关闭当前页
					Utils.closeCurrentPage();
				}
			});
		}, function(err, code) {
			Utils.msgDialog(err+"[code:"+code+"]");
		}
	);
}

</script>